<template>
	<view>
		<jhx-teacher-list :status="loadStatus" :list="lists"></jhx-teacher-list>
	</view>
</template>

<script>
	import jhxTeacherList from "@/components/jhx-teacher-list/jhx-teacher-list.vue";
	import {Teacher} from '@/model/teacher.js';
	var teacher = new Teacher();
	export default {
		components: {jhxTeacherList},
	    data() {
	        return {
				current:0,  //当前分类
				category:[
					{id:''}
				], //完整的分类对象
				cates:['全部'], //分类名称数组
				lists:[],
				loadStatus:'more',
				page : 1
	        }
	    },
	    onLoad() {
			this.getTeacher(); 
	    },
		//加载更多
		onReachBottom() {
			if(this.loadStatus == 'noMore'){
				return false;
			}
			this.page++;
			this.getTeacher();
		},
		methods: {
			
			//产品
			getTeacher:function(){
				var that = this;
				var page_size = 10;
				var param = {
					'page_size':page_size,
					'page':this.page
				};
				that.$data.loadStatus = 'loadding';
				
				teacher.lists(param,(data) => {
					var items = that.$data.lists.concat(data.data);
					this.lists=items;
					
					if(data.data.length < page_size){
						that.$data.loadStatus = 'noMore';
					}else{
						that.$data.loadStatus = 'more';
					}
				});
			},
			//分类切换
			onClickItem(val) {
				var that = this;
				this.current = val.currentIndex;
				if(!that.$data.productList[this.current]){
					this.getProduct();
				}
				
			},
			scollSwiper(e){
				this.current = e.target.current
			},
			
		},
	}
</script>

<style>
</style>
